package info.fqtech.skb.demo.utils;

import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Properties;

/**
 * @author YASSER
 * @version: 1.0.0
 * @description: 商户对象参数对象
 * @modified: <文件修改说明>
 */
public class MerchantConfig {

    /**
     * 商户号
     */
    public static String MER_CODE = null;

    /**
     * 商户号秘钥
     */
    public static String MER_KEY = null;

    /**
     * 订单创建方式
     */
    public static String MAKE_ORDER_TYPE = null;

    /**
     * 收款账号
     */
    public static String MER_ACCOUNT = null;

    /**
     * 下单获取支付信息网关地址
     */
    public static String PAY_ORDER_GATEWAY = null;

    /**
     * 订单状态查询网关
     */
    public static String QUERY_PAY_ORDER_STATUS_GATEWAY = null;

    /**
     * 支付结果回调通知地址
     * 1、地址必须是公网可以访问
     * 2、地址不可有参数
     * 3、地址中不能出现 select|update|union|and|or|delete|insert|trancate|char|into|substr|ascii|declare|exec|count|master|into|drop|execute
     */
    public static String PAY_ORDER_NOTIFY_URL = null;

    static {
        Properties properties = null;
        InputStreamReader in = null;
        try {
            in = new InputStreamReader(MerchantConfig.class.getClassLoader().getResourceAsStream("merchant.properties"), "UTF-8");
            properties = new Properties();
            properties.load(in);
            MER_CODE = properties.getProperty("mer_code");
            MER_KEY = properties.getProperty("mer_key");
            MAKE_ORDER_TYPE = properties.getProperty("make_order_type");
            MER_ACCOUNT = properties.getProperty("mer_account");
            PAY_ORDER_GATEWAY = properties.getProperty("pay_order_gateway");
            QUERY_PAY_ORDER_STATUS_GATEWAY = properties.getProperty("query_pay_order_status_gateway");
            PAY_ORDER_NOTIFY_URL = properties.getProperty("pay_order_notify_url");
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if(in != null){
                try {
                    in.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }

}
